//
//  VideoListTableViewCell.m
//  LOL_PalmarHelper
//
//  Created by dlios on 15-6-20.
//  Copyright (c) 2015年 hantao. All rights reserved.
//

#import "VideoListTableViewCell.h"
#define WITH 375
#define HEIGHT 667
#define CURRENTwith [UIScreen mainScreen].bounds.size.width
#define CURRENTheight [UIScreen mainScreen].bounds.size.height



@implementation VideoListTableViewCell
- (void)dealloc
{
    [_data release];
    [_label1 release];
    [_label2 release];
    [_label3 release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        [self createSubView];
    }
    
    return self;
}

- (void)createSubView
{
    

    
    //    两种方法
    
    self.imageview1 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 80, 80)];
    
    
    //    self.imageview1.backgroundColor = [UIColor lightGrayColor];
    
    [self.contentView addSubview:self.imageview1];
    
//    NSLog(@"%f",self.contentView.bounds.size.width);
    
    self.label1 = [[UILabel alloc] initWithFrame:CGRectMake(95, 10, [UIScreen mainScreen].bounds.size.width - 150, 30)];
    
    //    self.label1.backgroundColor = [UIColor greenColor];
    
    [self.contentView addSubview:self.label1];
    
    self.label1.lineBreakMode = NSLineBreakByWordWrapping;
    
    self.label1.font = [UIFont systemFontOfSize:13];
    
    self.label1.numberOfLines = 0;
    
    
    UIButton *shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
    shareButton.frame = CGRectMake(CURRENTwith/WITH*320, CURRENTheight /HEIGHT *20, CURRENTwith/WITH*45, CURRENTheight /HEIGHT *45);
    shareButton.backgroundColor = [UIColor clearColor];
    
    [shareButton setImage:[UIImage imageNamed:@"iconfont-fenxiang.png"] forState:UIControlStateNormal];
    [shareButton addTarget:self action:@selector(shareBUtton) forControlEvents:UIControlEventTouchUpInside];
    
  
    
    
    self.label2 = [[UILabel alloc] initWithFrame:CGRectMake(95, 70, [UIScreen mainScreen].bounds.size.width - 150, 30)];
    
    //    self.label1.backgroundColor = [UIColor greenColor];
    
    [self.contentView addSubview:self.label2];
    
    self.label2.font = [UIFont systemFontOfSize:12];
    
    self.label2.numberOfLines = 1;
    
    
    self.label3 = [[UILabel alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - 50, 50, 80, 30)];
    
    //    self.label1.backgroundColor = [UIColor greenColor];
    
    [self.contentView addSubview:self.label3];
    
    self.label3.font = [UIFont systemFontOfSize:12];
    
    self.label3.numberOfLines = 1;
    
    
    [self.contentView addSubview:shareButton];
    

    
    [_label1 release];
    [_label2 release];
    [_label3 release];
    
    
}




-(void)shareBUtton
{

    
    
    [self.videoDelegate shareVideo:self.label1.text andIndexpath:self.myIndexpath];
    
}


-(void)setData:(VideoListModel *)data
{
    
    
   
    
    [self.imageview1 sd_setImageWithURL:[NSURL URLWithString:data.cover_url]];
        
    self.label1.text = data.title;
    
    self.label2.text = data.upload_time;
    
    NSInteger a = [data.video_length integerValue];
    
    NSInteger b = a / 60;
    
    NSInteger c = a % 60;
    
    NSString *str = [NSString stringWithFormat:@"%ld:%ld", (long)b, (long)c];
    
    self.label3.text = str;
    
    
    
}


























- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
